#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        if (nums.size() <= 2)
            return nums.size();

        int s = 2, f = 2;

        while (f < nums.size())
        {
            if (nums[s - 2] != nums[f])
            {
                nums[s] = nums[f];
                s++;
            }
            f++;
        }
        return s;
    }
};